package online.longzipeng.back.pojo.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Author: lzp
 * @Description: 消息动作枚举
 * @Date: Created in 11:19 2022/6/6
 */
@AllArgsConstructor
@Getter
public enum MessageActionEnum {

    // 各种消息动作
    KEEPALIVE(0, "客户端保持心跳"),
    CONNECT(1, "第一次(或重连)初始化连接"),
    GROUP_INVITATION(2, "团队邀请"),
    SIGNED(3, "消息签收"),
    GROUP_INVITE(4, "团队邀请"),
    PULL_FRIEND(5, "拉取好友");

    /**
     * 动作类型
     */
    private Integer type;

    /**
     * 动作内容
     */
    private String content;

    /**
     * 通过类型获取枚举类
     *
     * @param type
     * @return
     */
    static MessageActionEnum getByType(Integer type) {
        MessageActionEnum[] values = values();
        for (MessageActionEnum value : values) {
            if (ObjectUtil.equal(value.type, type)) {
                return value;
            }
        }
        return null;
    }

}
